package com.xxx.mall.context;

import com.xxx.mall.bo.AuthAccountBO;

/**
 * @author 邢晨旭
 * {@code @date} 2023/11/16
 */
public class AuthUserContext {
    /**
     * The request holder.
     */
    private static final ThreadLocal<AuthAccountBO> USER_INFO_IN_TOKEN_HOLDER = new ThreadLocal<>();

    public static AuthAccountBO get() {
        return USER_INFO_IN_TOKEN_HOLDER.get();
    }


    public static void set(AuthAccountBO authAccountBO) {
        USER_INFO_IN_TOKEN_HOLDER.set(authAccountBO);
    }

    public static void clean() {
        if (USER_INFO_IN_TOKEN_HOLDER.get() != null) {
            USER_INFO_IN_TOKEN_HOLDER.remove();
        }
    }
}
